import {reqOrderConfirmInfo, reqFareInfo} from '@/api'

//trade模块的小仓库
const state = {
  orderConfirmInfo: {},
  fareInfo: {}
}
//mutation是唯一修改state的地方
const mutations = {
  GETORDERCONFIRMINFO(state, orderConfirmInfo) {
    state.orderConfirmInfo = orderConfirmInfo
  },
  GETFAREINFO(state, fareInfo) {
    state.fareInfo = fareInfo
  },
}
const actions = {
  //获取用户订单信息
  async getOrderConfirmInfo({commit}) {
    let result = await reqOrderConfirmInfo()
    if (result.code === 0) {
      commit("GETORDERCONFIRMINFO", result.data)
    }
  },
  //获取运费信息
  async getFareInfo({commit}, parsms) {
    let result = await reqFareInfo(parsms)
    if (result.code === 0) {
      commit("GETFAREINFO", result.data)
    }
  },
}
//计算属性
const getters = {}
export default {
  state,
  mutations,
  actions,
  getters
}
